package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.AccountActiveStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * @author linyangping
 * @date 2019/9/5
 */
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "user")
public class UserEntity extends CreatorPersistenceEntity {

    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(name = "id", unique = true, columnDefinition = ("varchar(40) not null comment '主键uuid'"))
    private String id;

    @Column(name = "phone", columnDefinition = ("varchar(15) not null comment '手机号码'"))
    private String phone;

    @Column(name = "username", columnDefinition = ("varchar(40) default null comment '用户名'"))
    private String username;

    @Column(name = "email", columnDefinition = ("varchar(50) default null comment '邮箱地址'"))
    private String email;

    @Column(name = "email_status", columnDefinition = ("int(1) default 0 comment '邮箱状态'"))
    private Integer emailStatus;

    @Column(name = "auth_status", columnDefinition = ("int(1) default 0 comment '认证状态'"))
    private Integer authStatus;

    @Column(name = "auth_type", columnDefinition = ("int(1) default 0 comment '认证类型'"))
    private Integer authType;

    @Column(name = "status", columnDefinition = ("int(1) default 0 comment '用户状态'"))
    private Integer status;

    @Column(name = "lock_time", columnDefinition = ("varchar(20) default 0 comment '账号错误次数过多锁定时间'"))
    private String lockTime;

    @Column(name = "error_count", columnDefinition = ("int(11) default 0 comment '账号错误次数'"))
    private Integer errorCount;

    @Column(name = "address", columnDefinition = ("varchar(255) default null comment '用户地址'"))
    private String address;

    @Column(name = "enterprise_name", columnDefinition = "varchar(64) default null comment '企业名称'")
    private String enterpriseName;

    @Column(columnDefinition = ("tinyint(1) not null default 1 comment '启用'"))
    private Boolean enable = true;

    @Column(columnDefinition = ("varchar(64) default null comment '描述'"))
    private String description;

    @Column(columnDefinition = ("varchar(40) default null comment '所属商户Id'"))
    private String merchantId;

    @Column(columnDefinition = ("varchar(64) default null comment '所属商户名'"))
    private String merchantName;

    @Column(columnDefinition = ("varchar(32) default null comment '激活状态'"))
    @Enumerated(EnumType.STRING)
    private AccountActiveStatus activateStatus;
}
